#include "QuickTemplateObject.h"

#include <QJsonDocument>
#include <QJsonArray>
#include <QJsonObject>
#include <NetworkRequest/NetworkRequest.h>
#include <QtPrivateDeclar/QtPrivateDeclar.h>


QuickTemplateObject::QuickTemplateObject(QObject *parent) : QObject(parent) {

    NetworkRequest *request = new NetworkRequest;
    
    connect(request, &NetworkRequest::replyRequest, [=](const QString &content){
        QJsonDocument document = QJsonDocument::fromJson(content.toLocal8Bit());
        for (auto array : document.array())
        {
            QtPrivateDeclar *obj = new QtPrivateDeclar();
            obj->setObject(array.toObject());
            m_list.append(obj);
        }

        emit loaded(m_list);
    });

    request->requestString("https://cpu.bmcx.com/web_system/bmcx_com_www/system/file/cpu/get_data/?lx=cpu&s=1&e=999999");
}